package com.llh.activitidemo.datatest;

import com.llh.activitidemo.dao.SysUserDAO;
import com.llh.activitidemo.model.SysUser;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.Arrays;

/**
 * <h2>InitMockData</h2>
 * <p>Description</p>
 * <p>CreatedAt: 2020-04-14 23:14</p>
 * <p><a href="mailto:forever2y_y@163.com">SendMailToMe</a></p>
 *
 * @author llh
 */
@SpringBootTest
public class InitMockData {

    @Autowired
    private SysUserDAO userDAO;

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Test
    public void testAddUser() {
        SysUser u1 = new SysUser();
        u1.setUsername("Tom");
        u1.setPassword(passwordEncoder.encode("123"));
        SysUser u2 = new SysUser();
        u2.setUsername("Jerry");
        u2.setPassword(passwordEncoder.encode("123"));
        userDAO.saveAll(Arrays.asList(u1, u2));
    }
}
